﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Extra.ERP;
using APP.HELPER.Utils.Language;
using Common.Class;

namespace Security.Security
{
    public class xfmUsers : XtraForm
    {
        private bool _search;
        private IContainer components;
        private xucUser ucList;

        public event ItemSelectedEventHander ItemSelected;

        public xfmUsers()
        {
            this.components = null;
            this._search = false;
            this.InitializeComponent();
            this.Init();
        }

        public xfmUsers(bool search)
        {
            this.components = null;
            this._search = false;
            this._search = search;
            this.InitializeComponent();
            this.Init();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            SYS_LOG.Insert("Quản L\x00fd Người D\x00f9ng", "Xem");
            this.ucList.ReLoad();
            this.ucList.CloseClick += new ButtonClickEventHander(this.ucList_CloseClick);
            this.Text = (MultiLanguages.Language() == "vi-VN") ? this.Text : "User Management";
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmUsers));
            this.ucList = new xucUser();
            base.SuspendLayout();
            this.ucList.Dock = DockStyle.Fill;
            this.ucList.Location = new Point(0, 0);
            this.ucList.Name = "ucList";
            this.ucList.Size = new Size(0x26a, 0x1bd);
            this.ucList.TabIndex = 0;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x26a, 0x1bd);
            base.Icon = (Icon)manager.GetObject("$this.Icon");
            base.Controls.Add(this.ucList);
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmUsers";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "Người D\x00f9ng";
            base.ResumeLayout(false);
        }

        private void RaiseItemSelectedEventHander(SYS_USER item)
        {
            if (this.ItemSelected != null)
            {
                this.ItemSelected(this, item);
            }
        }

        private void ucList_CloseClick(object sender)
        {
            base.Close();
        }

        public bool IsSearch
        {
            set
            {
                this.ucList.IsSearch = value;
            }
        }

        public delegate void ItemSelectedEventHander(object sender, SYS_USER item);
    }

}
